package com.JustTest;

import com.alibaba.fastjson.JSON;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.kafka.clients.producer.Callback;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.Producer;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.clients.producer.RecordMetadata;

import java.util.Arrays;
import java.util.Date;
import java.util.Properties;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

/**
 * Created by mike on 18/1/31.
 */
public class App2 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        Properties props = new Properties();
        props.put("bootstrap.servers", "127.0.0.1:9092");
        props.put("batch.size", 16384);
        props.put("linger.ms", 1);
        props.put("buffer.memory", 33554432);
        props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
        props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
        Community community = new Community();
        community.setCommunityId(276613);
        Producer<String, String> procuder = new KafkaProducer<String,String>(props);
        ProducerRecord<String, String> msg = new ProducerRecord<String, String>("lmesdevtest", "123123");
        Future<RecordMetadata> future = procuder.send(msg);
        while(true){
            if(future.isDone()) {
                System.out.println("++++++++"+future.get().topic()+" "+future.get().offset()+" "+msg.value());
                return;
            }
        }
//        ApplicationContext app = new ClassPathXmlApplicationContext("beans.xml");
//        Test test = (Test) app.getBean("test");
//        System.out.println(test.getA());
//        System.out.println(test.getB());
//        System.out.println(test.getC());
//        MyEmbeddedValueResolverAware my = (MyEmbeddedValueResolverAware) app.getBean("myEmbeddedValueResolverAware");
//        System.out.println(my.getPropertiesValue("${filter.test}"));

//        DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
//        ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
//        Resource res = resolver.getResource("classpath:beans.xml");
//        XmlBeanDefinitionReader reader=new XmlBeanDefinitionReader(factory);
//        reader.loadBeanDefinitions(res);
//        factory.addBeanPostProcessor(new MyBeanPostProcessor());
//        Test test = factory.getBean("test",Test.class);
//        System.out.println("args = [" + args + "]");
//        Str  ing a = "1234";
//        int length = a.length();

//        System.out.println(length);
//        System.out.println(a.codePointCount(0,length));

//
//        int[] a = {1, 2, 3, 4, 5};
//        int[] b = {2, 3, 4};
//        b = Arrays.copyOf(a, a.length * 2);
//        //b =  a;
//        System.out.println(JSON.toJSONString(b));
    }
}
